package com.eschool.beans.datamodels;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.eschool.model.School;
import com.eschool.model.Student;
import com.eschool.model.Teacher;

public class TeacherDataModel extends ListDataModel<Teacher> implements SelectableDataModel<Teacher>, Serializable {  

    public TeacherDataModel() {
    }

    public TeacherDataModel(List<Teacher> data) {
        super(data);
    }
    
    @Override
    public Teacher getRowData(String rowKey) {
        List<Teacher> teachers = (List<Teacher>) getWrappedData();
        
		for (Teacher teacher : teachers) {
            if(Integer.toString(teacher.getTeacherId()).equals(rowKey))
                return teacher;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(Teacher teacher) {
        return teacher.getTeacherId();
    }
}